<template>
    <div>

        <Head />
        <el-table :data="state.tableData" border style="width: 100%">
            <el-table-column prop="date" label="Date" width="180" />
            <el-table-column prop="name" label="Name" width="180" />
            <el-table-column prop="address" label="Address" />
            <el-table-column fixed="right" label="Operations" width="120">
                <template #default>
                    <el-button link type="primary" size="small" @click="edit">编辑</el-button>
                    <el-button link type="primary" size="small" @click="del">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <Page />
        <editComponent ref="dialogRef"  />
    </div>
</template>

<script lang="ts" setup>
import { ref, reactive, defineAsyncComponent } from 'vue'

const dialogRef = ref();
const editComponent = defineAsyncComponent(() => import('./editDialog.vue'));
const Head = defineAsyncComponent(() => import('@/components/head.vue'));
const Page = defineAsyncComponent(() => import('@/components/pagination.vue'));


const state = reactive({
    tableData: [
        { date: '2016-05-02', name: '王小虎', address: '上海市普陀区金沙江路 1518 弄' },
        { date: '2016-05-04', name: '王小虎', address: '上海市普陀区金沙江路' },
        { date: '2016-05-01', name: '王小虎', address: '上海市普陀区金沙江路 1517 弄' },
        { date: '2016-05-03', name: '王小虎', address: '上海市普区金沙江路 1519 弄' }]
})

const edit = () => {
    dialogRef.value.openDialog();
}
const del = () => {
    console.log('delete')
}
</script>


<style scoped></style>